﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
using DTO;
//0712455
namespace DAO
{
    public class LoaiTienTeDAO
    {
        public static List<LoaiTienTeDTO> LayDanhSach()
        {
            SqlConnection cnn = KetNoiCSDL.TaoKetNoi();
            string query = "select * from Loai_Tien_Te";
            SqlCommand cmd = new SqlCommand(query, cnn);

            cnn.Open();
            List<LoaiTienTeDTO> lstLoaiTienTe = new List<LoaiTienTeDTO>();
            try
            {
                SqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    LoaiTienTeDTO loaiTienTeDto = new LoaiTienTeDTO();
                    loaiTienTeDto.MaLoaiTienTe = (int)dr["MaLoaiTienTe"];
                    loaiTienTeDto.TenLoaiTienTe = dr["TenLoaiTienTe"].ToString();

                    lstLoaiTienTe.Add(loaiTienTeDto);
                }
                cnn.Close();
                return lstLoaiTienTe;

            }
            catch (Exception ex)
            {
                if (cnn.State == ConnectionState.Open)
                    cnn.Close();
                throw ex;
            }

        }
    }
}
